﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="OneMG.Phoenix.AdminSite._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>SWFUpload Application Demo (ASP.Net 2.0)</title>
    <link href="/Scripts/swfupload/default.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="/Scripts/swfupload/swfupload.js"></script>

    <script type="text/javascript" src="/Scripts/swfupload/handlers.js"></script>

    <script type="text/javascript" src="/Scripts/swfupload/swfupload.queue.js"></script>

    <script type="text/javascript" src="/Scripts/swfupload/swfupload.swfobject.js"></script>

    <script type="text/javascript" src="/Scripts/swfupload/fileprogress.js"></script>

    <script src="/Scripts/jquery.js" type="text/javascript"></script>

    <style type="text/css">
        a.spb-upload-button
        {
            background: url("/Scripts/swfupload/upload-button.png") no-repeat scroll 0 -160px transparent;
            color: #999999;
            display: inline-block;
            font-size: 14px;
            font-weight: bold;
            height: 30px;
            margin: 0 5px;
            padding-top: 10px;
            text-align: center;
            width: 140px;
        }
        a.progressCancel
        {
            background: url("/Scripts/swfupload/tn-icons-sprite-999999.png") repeat scroll -80px -16px transparent;
            display: block;
            float: right;
            height: 16px;
            margin: 3px 2px;
            width: 16px;
        }
    </style>

    <script type="text/javascript">
        var swfu;
        //需要设置的参数：
        //upload_url：处理上传文件的Url，
        //file_types：能够上传的文件类型，例如："*.jpg;*.gif" 用英文分号隔开，
        //file_queue_limit：允许排队的文件总数，0为不限制 ，
        //file_size_limit：单个文件大小的限制 参数接收一个单位，有效的单位有B、KB、MB、GB，默认单位是KB。例如: 2147483648 B, 2097152, 2097152KB, 2048 MB, 2 GB
        //attributes：需要传给后端进行处理的控件ID，例如："categoryID;tagName"
        window.onload = function() {
            var settings = {
                flash_url: '/Scripts/swfupload/swfupload.swf',
                upload_url: 'upload.ashx',
                post_params: {
                    "currentUserID": "ouYRK+CtMV9StDGtsiZomA=="
                },
                file_size_limit: '5120',
                file_types: '*.gif;*.jpg;*.jpeg;*.png;*.bmp;',
                file_types_description: "All Files",
                file_queue_limit: '11',
                custom_settings: {
                    progressTarget: "fsUploadProgress",
                    cancelButtonId: "btnCancel"
                },
                debug: false,

                // Button settings
                button_image_url: '/Scripts/swfupload/upload-button.png', // Relative to the Flash file
                button_width: "140",
                button_height: "40",
                button_placeholder_id: "spanButtonPlaceholder",
                button_text: '<span class="theFont">浏览</span>',
                button_text_style: ".theFont { font-size: 14px; font-weight: bold; text-align: center; color:#333333; }",
                button_text_left_padding: 0,
                button_text_top_padding: 10,

                // The event handler functions are defined in handlers.js
                file_queued_handler: fileQueued,
                file_queue_error_handler: fileQueueError,
                file_dialog_complete_handler: fileDialogComplete,
                upload_start_handler: uploadStart,
                upload_progress_handler: uploadProgress,
                upload_error_handler: uploadError,
                upload_success_handler: function(file, serverData) {
                    thumpathCallBack(serverData);
                    var serverData = eval('(' + serverData + ')');
                    var progress = new FileProgress(file, this.customSettings.progressTarget);
                    if (!serverData.ok && serverData.message) {
                        progress.setError();
                        progress.toggleCancel(false);
                        progress.setStatus(serverData.message);
                        this.customSettings.queue_upload_count--;
                    }
                    else {
                        progress.setComplete();
                        progress.setStatus("完成.");
                    }
                },
                upload_complete_handler: uploadComplete,
                queue_complete_handler: allUploadHandler	// Queue plugin event
            };
            swfu = new SWFUpload(settings);
        };

        function uploadAttachmentsStart() {
            swfu.addPostParam('associateID', '13767');
            swfu.startUpload();
        }
	     
    </script>

    <script type="text/javascript">
        function allUploadHandler(numFilesUploaded) {
            // $("#SWFUpload_0").hide();
            //$("#btnCancel").attr('style', 'display:none');
            // $("#uploadrOk").attr('style', 'display:block');
            $("#editUploadPhotos").attr('href', '/u/jcgh/Photo/EditPhotos' + "?photoCount=" + numFilesUploaded.toString());
            $("#advanceSettingOutDiv").attr('style', 'display:none');
        }

        var uploadPhotosClick = function() {
            if ($('.progressWrapper:visible').length < 1) {
                alert('请选择上传的图片')
            } else {
                $('#advanceSettingOutDiv').attr('style', 'display:none');
                uploadAttachmentsStart();
            }
        }

        function thumpathCallBack(file) {
            var html = "<input id=\"Checkbox1\" type=\"checkbox\" /><img alt=\"\" src=" + file + " />";
        $("#thum").append(html);
        }
    </script>

</head>
<body>
    <div>
        <span id="spanButtonPlaceholder"></span><a id="btnCancel" class="spb-upload-button"
            disabled="disabled" onclick="swfu.cancelQueue();" href="javascript:;">清空列表</a>
    </div>
    <div id="flashUploadFiles">
        <div class="fieldset flash" id="fsUploadProgress">
            <span class="legend">上传列表</span>
        </div>
        <div class="legend" id="divStatus">
        </div>
    </div>
    <button type="button" onclick="uploadPhotosClick();" id="uploadPhotos">
        上传</button><a id="candlerUploadPhotos">取消</a>
    <div id="thum">
    </div>
</body>
</html>
